package com.homework.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.time.ZoneId;
import java.util.TimeZone;

@Configuration
public class TimeZoneConfig implements WebMvcConfigurer {

    /**
     * 设置时区为Asia/Shanghai
     */
    @Bean
    public ZoneId zoneId() {
        return ZoneId.of("Asia/Shanghai");
    }

    /**
     * 设置JVM默认时区
     */
    @Bean
    public TimeZone timeZone() {
        return TimeZone.getTimeZone("Asia/Shanghai");
    }
}